package com.endurance.service.impl;

import com.endurance.dao.TestADao;
import com.endurance.pojo.Transfer;
import com.endurance.service.TestServiceA;
import com.endurance.service.TestServiceB;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TestServiceAImpl implements TestServiceA {

    @Autowired
    private TestADao testADao;

    @Autowired
    private TestServiceB testServiceB;

    @Override
    public void updateA() {
        testADao.update(new Transfer("张三", +1000.0));
        try {
            testServiceB.updateB();
        } catch (Exception e) {
            System.out.println("捕获B的异常...");
            e.printStackTrace();
        }
    }

    @Override
    public void reset() {
        testADao.reset(new Transfer("张三", 2000.0));
        testADao.reset(new Transfer("李四", 6000.0));
    }

    @Override
    public void list() {
        for (Transfer transfer : testADao.list()) {
            System.out.println(transfer);
        }
    }
}
